
package org.wing.mouseListener;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import org.come.Frame.TestpackJframe;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.TestpackJapnel;
import org.come.Jpanel.ZhuJpanel;
import org.come.entity.Goodstable;
import org.come.until.GoodsListFromServerUntil;
import org.come.until.MessagrFlagUntil;
import org.wing.panel.WingMainPanel;

public class WingGoodsListMouseLitener extends MouseAdapter
{

	private int type;
	private WingMainPanel wingMainPanel;

	public WingGoodsListMouseLitener(int type, WingMainPanel wingMainPanel)
	{
		this.type = type;
		this.wingMainPanel = wingMainPanel;
	}

	@Override
    public void mousePressed(MouseEvent e)
	{
		if (e.getButton() == 3)
		{
			if (type + (wingMainPanel.getPageNumber() - 1) * 25 >= GoodsListFromServerUntil.getWingGoodsList().size()) {
                return;
            }
			Goodstable goodstable = (Goodstable)GoodsListFromServerUntil.getWingGoodsList().get(type + (wingMainPanel.getPageNumber() - 1) * 25);
			wingMainPanel.changeChooseWingGoods(goodstable, type + (wingMainPanel.getPageNumber() - 1) * 25);
		}
	}

	@Override
    public void mouseEntered(MouseEvent e)
	{
		if (type + (wingMainPanel.getPageNumber() - 1) * 25 >= GoodsListFromServerUntil.getWingGoodsList().size()) {
            return;
        }
		Goodstable goodstable = (Goodstable)GoodsListFromServerUntil.getWingGoodsList().get(type + (wingMainPanel.getPageNumber() - 1) * 25);
		if (goodstable != null){
			MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE12);
		}
			ZhuFrame.getZhuJpanel().creatgoodtext(goodstable);
	}

	@Override
    public void mouseExited(MouseEvent e) {
		MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE1);
		TestpackJframe.getTestpackJframe().getJpac().ClearText();
		ZhuFrame.getZhuJpanel().cleargoodtext();
	}

	public int getType()
	{
		return type;
	}

	public void setType(int type)
	{
		this.type = type;
	}
}
